package com.jessechanrui.template.skeleton.common.base;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
import java.util.Date;

/**
 * 持久化对象PO基类
 * 	抽取公共字段
 * @author chenrui
 * @date 2024/1/29
 */
@Data
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class BasePO implements Serializable {

	private static final long serialVersionUID = 3567846355853017142L;

	/**
	 * 创建时间
	 */
	@JsonProperty("created_date")
	@CreatedDate
	@Column(name = "created_date", updatable = false)
	private Date createdDate;

	/**
	 * 创建人
	 */
	@JsonProperty("created_by")
	@Column(name = "created_by", updatable = false)
	@CreatedBy
	private String createdBy;

	/**
	 * 更新时间
	 */
	@JsonProperty("updated_date")
	@Column(name = "updated_date")
	@LastModifiedDate
	private Date updatedDate;

	/**
	 * 更新人
	 */
	@JsonProperty("updated_by")
	@Column(name = "updated_by")
	@LastModifiedBy
	private String updatedBy;

	/**
	 * 逻辑删除
	 */
	@JsonProperty("del_flag")
	@Column(name = "del_flag",columnDefinition = "varchar(1)")
	private Boolean delFlag = false;

}
